﻿//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//    Crolengi, this program (a part of program) is gameengine based on C++\Directx
//    Copyright (C) 2008 Pashinin Anton Alekseevich (Crol)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//    (INCLUDING NEGLIGENCE OR OTHERWISE) 
//    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
//    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//    Contacts: 
//    Mail: crolengi@gmail.com
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#ifndef  GInterface_h
#define  GInterface_h

#include "..\\import\\CRLEngi_strings_lib\\CRLEngi_strings.h"
#include "include\\Utils\\DrawingFunctions.h"
#include "include\\Utils\\defines01.h"

#include "include\\UI\\EditBox.h"
#include "include\\UI\\TextBox.h"
#include "include\\UI\\MLabel.h"
#include "include\\Utils\\Timer.h"

#include "include\\Managers\\Camera_Manager.h"
//#################################################################################################################
///// 
/////   :: РљР›РђРЎРЎ :: 
///// 
//#################################################################################################################
class CLREngi_UI_GInterface
{
  protected:
	LPDIRECT3DDEVICE9        *Device;
	CLREngi_UI_MLabel        *Caption_Label;
	Timer                    Timer;

	D3DXMATRIX          Camera_matrix;

	CLREngi_Camera_Manager* CameraMngr;


 CRLEngi_string  S1,S2;
char  c1[1024],c2[1024];
float x,y,z; int rez,time;
int time_until_end,time_passed;
CRLEngi_string EEvent;
CRLEngi_string params;

public:
//#################################################################################################################
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Show_Message(char* a){
      Caption_Label->SetText(a);
	  Timer.getCurrentTime();
	  Caption_Label->visible = true;
	  Caption_Label->ZENABLE(false);
	  
	  Caption_Label->Setup_Color(D3DCOLOR_XRGB(0,0,0),
								 D3DCOLOR_XRGB(50,50,50),
								 D3DCOLOR_XRGB(255,242,0));

	  Caption_Label->Setup_SizePos(20,600,strlen(a)*8,22);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Update_Caption_Label_pos(){
	int time = Timer.getElapsedTimeSeconds();
	if (Caption_Label->visible)
	  if (time<5){
		  
	     Caption_Label->set_Main_Matrix(CameraMngr->get_currient_ViewPos());
         Caption_Label->Render();
	  }
	  else Caption_Label->visible = false;

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Render(){
	Update_Caption_Label_pos();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_cam_mngr(CLREngi_Camera_Manager* CamMngr){
	CameraMngr = CamMngr;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_Camera_Matrix(D3DXMATRIX          Camera){
	Camera_matrix = Camera;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool    AnalyzeCommand(CRLEngi_string  Command){

	S1.clear();S2.clear();
	sscanf(Command.getChars(),"%s %1024[^'@']",c1,c2);
	S1=c1; S2=c2;
    S1.HideHoles();

	 if (S1 == "Show_Message"){ //"object setForce x,y,z str_type bool_wakeup"		   
		      Show_Message(c2);	 
	 }

return true;
}
//#################################################################################################################
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                     РљРћРќРЎРўР РЈРљРўРћР 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public:
CLREngi_UI_GInterface(LPDIRECT3DDEVICE9 *D){
   Device = D;
   Caption_Label = new CLREngi_UI_MLabel(Device,"Message:");
   Caption_Label->Setup_Color(D3DCOLOR_XRGB(0,0,0),
								 D3DCOLOR_XRGB(41,47,99),
								 D3DCOLOR_XRGB(255,242,0));
   Caption_Label->Setup_SizePos(20,600,20,17);
   
   Caption_Label->SetText("Р’С‹ С‰РµР»РєРЅСѓР»Рё РїРѕ РєСѓР±Сѓ");
   Caption_Label->visible = true;
   Timer.intialize();
   Timer.getCurrentTime();

   }
CLREngi_UI_GInterface(){ };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                       Р”Р•РЎРўР РЈРљРўРћР 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
~CLREngi_UI_GInterface(void)
   {

   }

};
//#################################################################################################################
#endif 

